This page last changed on Dec 31, 2007 by [email protected].


Building and Debugging GeoServer with Eclipse

. In this section you will:

  • Import GeoServer modules into your Eclipse IDE
  • Run / Debug GeoServer using Eclipse

Prerequisites

Before building GeoServer with your Eclipse IDE you must:

  1. Setup your Eclipse IDE
  2. Build all GeoServer modules

Importing GeoServer Modules into Eclipse

  1. From the root of GeoServer source tree, execute the following maven command:
    [/dev/geoserver]% mvn eclipse:eclipse

    or, if you want source jars to be downloaded too for easier coding and debugging, run:

    [/dev/geoserver]% mvn -DdownloadSources=true eclipse:eclipse
  1. Switch to Eclipse
  2. From the main menu, select File -> Import -> General -> Exsisting Projects into Workspace
  3. "Select root directory", select the root directory of Geoserver
  4. Click on "Finish"

If your eclipse projects are filled with errors, it may be that you either did not set up Eclipse properly, or that you did not fully build Geoserver before attempting to setup the Eclipse projects. Go back and look again in the prerequisites section.

Error messages in Eclipse

After importing the project you will likely see errors on some projects related to EMF, the Eclipse Modelling Framework.  EMF is an Eclipse plugin used to develop certain parts of Geoserver, but is not needed for general development or building Geoserver in Eclipse.  If you would like to install EMF, it is available via the Eclipse plugin manager (in Eclipse, choose Help->Software Updates->Find and Install Updates...  The EMF plugins are available from the Callisto Discovery Site.)

 

Debugging from Eclipse with Jetty

There are two ways of debugging Geoserver using Eclipse.

  1. starting Jetty directly from the web module
  2. starting mvn jetty:run from within Eclipse

Option 1. allows for quicker setup and easier debugging, because you're running against your sources, every change you make is reflected immediatly in the Jetty app.
Option 2. provides quicker jsp compile times, and mimicks better what happens during production, but requires you to mvn install all the modules you changed during the debug process before restarting jetty (if you want it to pick up the changes), because with option 2 jetty references directly the jars in your maven repo, disregarding the sources loaded in your IDE.

Debugging starting Jetty as a java application

  1. Locate the org.vfny.geoserver.jetty.Start class in the web module (it's among the test classes).
  2. Start it (either in run or debug mode depending on what you want to do).

Debugging running maven jetty:run as a java application

  1. From the main menu select Run > Debug...
  2. On the Main tab:
    1. Set Project to "web"
    2. Set Main Class to "org.codehaus.classworlds.Launcher"
  3. On the Arguments tab:
    1. Set Program arguments to "jetty:run"
    2. Set VM arguments to "-Xmx512M -Dclassworlds.conf=<MAVEN_HOME>bin/m2.conf -Dmaven.home=<MAVEN_HOME>" (Replace MAVEN_HOME with the location of maven on your system)
  4. On the Classpath tab:
    1. Select web (default classpath) (under User Entries) and click Remove
    2. Select User Entries, and using the Add External JARs... button, add "<MAVEN_HOME>/core/boot/classworlds-1.1.jar"
  5. On the Source tab:
    1. Using the Add... button, add all the GeoServer projects in your workspace
  6. Click Apply
  7. Click Debug

Set up successfully, you should see the output of the normal "mvn jetty6:run" command show up in your Eclipse console.

Setting the Data Directory

In order to change or set the data directory when running from Eclipse:

  1. Change to the Arguments tab
  2. Add the argument "-DGEOSERVER_DATA_DIR=<path to your data directory>"

console.PNG (image/png)
Import.PNG (image/png)
importProjects.png (image/png)
arguments.png (image/png)
arguments.png (image/png)
classpath.png (image/png)
classpath.png (image/png)
classpath.png (image/png)
main.png (image/png)
main.png (image/png)
source.png (image/png)
dd.png (image/png)
Document generated by Confluence on Jan 16, 2008 23:26